package com.platform.unifiedweb.controller.admin;

import com.platform.common.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * describe:
 *
 * @author rainly
 * @date 2019/11/19
 * @time 4:11 下午
 */
@Controller
@RequestMapping(value = "admin")
public class AdminController extends BaseController {

    @GetMapping(value = "list")
    public ModelAndView list() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/admin/admin-list");
        return modelAndView;
    }

    @GetMapping(value = "add")
    public ModelAndView add() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/admin/admin-add");
        return modelAndView;
    }

    @GetMapping(value = "passwordEdit")
    public ModelAndView passwordEdit() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/admin/password-edit");
        return modelAndView;
    }

    @GetMapping(value = "permission")
    public ModelAndView permission() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/admin/admin-permission");
        return modelAndView;
    }

    @GetMapping(value = "role")
    public ModelAndView role() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/admin/admin-role");
        return modelAndView;
    }

    @GetMapping(value = "rolegroup")
    public ModelAndView rolegroup(@RequestParam(value="menuid") String menuid) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("menuid",menuid);
        modelAndView.addObject("parentid","top");
        modelAndView.setViewName("page/admin/rolegroup/admin-rolegroup");
        return modelAndView;
    }

    @GetMapping(value = "rolegroupEdit")
    public ModelAndView rolegroupEdit(@RequestParam(value="groleid") String groleid,@RequestParam(value="parentid") String parentid) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("groleid",groleid);
        modelAndView.addObject("parentid",parentid);
        modelAndView.setViewName("page/admin/rolegroup/admin-rolegroup-edit");
        return modelAndView;
    }

    /**
     * 管理员-菜单管理-列表
     * @param menuid 菜单id
     * @return 页面
     */
    @GetMapping(value = "menu")
    public ModelAndView menu(@RequestParam(value="menuid") String menuid) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("menuid",menuid);
        modelAndView.setViewName("page/admin/menu/admin-menu");
        return modelAndView;
    }

    /**
     * 管理员-菜单管理-编辑
     * @param menuid 菜单id
     * @return 页面
     */
    @GetMapping(value = "menuEdit")
    public ModelAndView menuEdit(@RequestParam(value="menuid") String menuid) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("menuid",menuid);
        modelAndView.setViewName("page/admin/menu/admin-menu-edit");
        return modelAndView;
    }

    @GetMapping(value = "roleAdd")
    public ModelAndView roleAdd() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/admin/admin-role-add");
        return modelAndView;
    }
}
